<?PHP 
session_start();

if(isset($_GET['logoff']))
    {
        session_destroy();
    }
else
    {
        include_once ('../_classes/_db-conf.php');

        $login = $_POST['login'];
        $senha = $_POST['senha'];

        $sql = 'SELECT * FROM usuario WHERE login_usu = "' . $login . '" AND senha_usu = "'.$senha.'";';
        echo $sql;
        $query = new query();
        $result = $query->exec($sql);

        if($query->numRows($result) > 0)
            {
                $listar = $query->listar($result);
                foreach ($listar as $row)
                {
                    $_SESSION['id_usu'] = $row['id_usu'];
                }
            }
         else
            {
                $_SESSION['avisoLogin'] = 'erroLogin';
            }
         session_write_close();
    }

header("location:" . $_REQUEST['url']);
?>